A system may use a device driver to communicate with a mouse, a printer, or other device. A common way of transferring data between two processes or between a process and a device driver includes copying data from a one memory buffer to another memory buffer. When an amount of data is large such as, for example, larger than 24 kilobytes (KB), or another suitable value, copying of data is too time-consuming. When the amount of data is large, a memory buffer may be directly mapped to an address space of another process or a device driver. Memory mapping has a granularity that is generally a size of a memory page, which may be 4 KB, 8 KB, or another size.
When a memory buffer does not start or end on a memory page boundary, the memory buffer is non-page aligned. When a memory page buffer is non-page aligned, data that is outside of the memory buffer, but within the memory page, may be exposed to a process or device driver having an address space to which the memory buffer is mapped. If a first one of a process or device driver does not trust a second one of the process or the device driver, having an address space to which the memory buffer is mapped, there is concern regarding whether the second one of the process or the device driver is able to access secret information of the first one of the process or the device driver, or is able to tamper with information of the first one of the process of the device driver. For example, if the first one of the process or the device driver is a kernel-mode driver and the second one of the process or the device driver is a process, then when the mapped memory buffer is non-page aligned, the process may access or modify passwords, other secret data, or control data within the kernel-mode driver address space, and/or the kernel-mode driver may access or modify data within the process address space. If a driver was, instead, a user-mode driver, a non-page aligned memory mapped buffer would allow a process, receiving a request and a buffer, to access an address space of a process which owns the buffer, but not vice versa.